#!/bin/bash
set -e
set -x
MYDIR="${0%/*}"
cd "$MYDIR/.."
source "recipes/common.sh"


# RECIPE START libzio-native
# depends: xz-native
# depends: zlib-native
# why: cross-compiling texinfo needs native texinfo

save_CFLAGS="$CFLAGS"
save_CPPFLAGS="$CPPFLAGS"
save_LDFLAGS="$LDFLAGS"
unset CFLAGS
unset CPPFLAGS
unset LDFLAGS

rm -rf build/libzio-native
cp -a libzio build/libzio-native

# libzio makefile is even worse than autocrap
make -C build/libzio-native \
	CC=gcc \
	AR=ar \
	RANLIB=ranlib \
	LIBS="-L${xtools}${build_prefix}/lib -lz -llzma" \
	CFLAGS="-I${xtools}${build_prefix}/include -fPIC -D_GNU_SOURCE -D_REENTRANT -DHAVE_FOPENCOOKIE -DHAS_ZLIB_H -DHAS_LZMA_H"  \
	RPMOPTFLAGS='-O2 -g' \
	INCLUDES="-I${xtools}${build_prefix}/include" \
	prefix=$build_prefix \
	libdir=$build_prefix/lib \
	DESTDIR=$xtools \
static install-static install-data

rm -rf build/libzio-native

export CFLAGS="$save_CFLAGS"
export CPPFLAGS="$save_CPPFLAGS"
export LDFLAGS="$save_LDFLAGS"

# RECIPE END libzio-native
